package com.example.springboot.util;

import com.example.springboot.mapper.EmailMapper;
import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.stereotype.Component;

@Component
public class ApplicationContextMine implements ApplicationContextAware {

    static ApplicationContext applicationContext;

    @Override
    public void setApplicationContext(ApplicationContext ac) throws BeansException {
        this.applicationContext=ac;
    }

    public static EmailMapper getEmailMapper(){

        return applicationContext.getBean("emailMapper",EmailMapper.class);
    }
}
